$(function(){
	detailOrder(GetQueryString("id"));
	$("#btnget").click(function(){
		opperate(GetQueryString("id"));
	})
})




$(document).ready(function(){
	
})
function GetQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if(r != null) return unescape(r[2]);
				return null;
			}

function detailOrder(id){
	$.ajax({
		//"url":"http://127.0.0.1/app/exp/lookDetail",
		"url":Server + "/app/exp/lookDetail",
		"type":"POST",
		//"dataType":"Json",
		"data" :{
			"id" : id
		},
		success : function(data){
			var m = data;
			var number1="";
			var address1="";
			if(m[0].insInfo != null && m[0].insInfo != "" && m[0].insInfo != undefined){
				number1=m[0].insInfo.number;
				address1=m[0].insInfo.address;
			}else{
				number1 = null;
				address1 = null;
			}
			var use1="";
			var way1="";
			var fundingCode1="";
			var time1="";
			var projectName1="";
			var fundingSource1="";
			var prinpical1="";
			if(m[0].orderappli != null && m[0].orderappli != "" && m[0].orderappli != undefined){
				use1 = m[0].orderappli.use;
				way1 = m[0].orderappli.way;
				fundingCode1 = m[0].orderappli.fundingCode;
				time1 = m[0].orderappli.time ;
				projectName1 = m[0].orderappli.projectName;
				fundingSource1 = m[0].orderappli.fundingSource;
				prinpical1 = m[0].orderappli.prinpical;
			}else{
				use1=null;
				way1=null;
				fundingCode1=null;
				time1=null;
				projectName1=null;
				fundingSource1=null;
				prinpical1=null;
			}
			$("#1").val(number1);
			$("#2").val(m[0].chineseName);
			$("#3").val(m[0].unitName);
			$("#4").val(address1);
			$("#5").val(m[0].realname);
			$("#6").val(m[0].phone);
			$("#7").val(m[0].email);
			$("#8").val(m[0].name);
			$("#9").val(m[0].iPhone);
			$("#10").val(m[0].unit);
			$("#11").val(m[0].createTime);
			$("#12").val(m[0].number);
			$("#13").val(use1);
			$("#14").val(way1);
			$("#15").val(fundingCode1);
			$("#16").val(time1);
			$("#17").val(projectName1);
			$("#18").val(fundingSource1);
			$("#19").val(prinpical1);
			
			var html = "";
			var item = '<tr>\
				<th>序号</th>\
				<th>测试内容</th>\
				<th>数量</th>\
				<th>预算费用</th>\
				<th>样品描述与测试要求</th>\
			</tr>';
			var pattern='<tr>\
				<td>#1</td>\
				<td>#2</td>\
				<td>#3</td>\
				<td>#4</td>\
				<td>#5</td>\
			</tr>'
				for(var m = 0; m < data[0].sample.length; m++){
					var num =m+1;
					var ll = 1;
					item += pattern
					   .replace("#1", num)
		               .replace("#2", data[0].sample[m].centent)
		               .replace("#3", data[0].sample[m].count)
		               .replace("#4", data[0].sample[m].fee)
		               .replace("#5", data[0].sample[m].desc)
		             
				}
				$("#SampleDetail").html(item);
		}
	})
}
function opperate(id3){
	$.ajax({
		"url":Server + "/app/exp/modifyStatus",
		//"url":"http://127.0.0.1/app/exp/modifyStatus",
		//url:Server + "/app/exp/modifyStatus",
		type : "POST",
		data:{
			"id" : id3,
			"status" : 4
		},
		success : function(data){
			alert("修改成功！");
			$(location).attr('href', 'book_admin25');
		},
		error : function(msg){
			alert("修改失败，请联系管理员！");
		}			
	})
}
